package com.web.common.basic.quartz.api;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.web.common.api.config.ServiceInstanceName;
import com.web.common.basic.quartz.entity.QuartzJobDetail;
import com.web.common.basic.quartz.entity.QuartzJobDetailEntity;
import com.web.common.basic.quartz.entity.QuartzJobExecLog;
import com.web.common.basic.quartz.entity.QuartzJobExecLogEntity;
import com.web.common.basic.quartz.entity.QuartzJobOperateLog;
import com.web.common.basic.quartz.entity.QuartzJobOperateLogEntity;
import com.web.common.basic.quartz.entity.QuartzJobParam;
import com.web.common.result.R;

@FeignClient(name = ServiceInstanceName.SERVICE_BASIC_NAME, contextId = "quartzApi", path = "/basic/quartz")
public interface QuartzApi {

	/**
	 * 获取定时任务列表
	 * 
	 * @param condition 查询条件
	 * @return R<IPage<QuartzJobEntity>> 定时任务列表
	 *
	 * @author zhouhui
	 * @since 2023.08.08
	 */
	@PostMapping(value = "/getJobList")
	@ResponseBody
	R<IPage<QuartzJobDetail>> getJobList(@RequestBody QuartzJobDetailEntity condition);
	
	/**
	 * 获取定时任务的
	 * @param job
	 * @return
	 *
	 * @author zhouhui
	 * @since 2023.11.19
	 */
	@PostMapping(value = "/getJobDetail")
	@ResponseBody
	R<QuartzJobParam> getJobDetail(@RequestBody QuartzJobParam job);

	/**
	 * 保存定时任务信息
	 * 
	 * @param job 任务信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.08.09
	 */
	@PostMapping(value = "/save")
	@ResponseBody
	R<Object> saveQuartzJob(@RequestBody QuartzJobParam job);

	/**
	 * 删除定时任务
	 * 
	 * @param job 任务信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.08.09
	 */
	@PostMapping(value = "/delete")
	@ResponseBody
	R<Object> deleteQuartzJob(@RequestBody QuartzJobParam job);

	/**
	 * 停用或者启用定时任务
	 * @param job 停用或启用的定时任务
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.08.14 
	 */
	@PostMapping(value = "/runOrStop")
	@ResponseBody
	R<Object> runOrStopQuartzJob(@RequestBody QuartzJobParam job);
	
	/**
	 * 执行一次任务
	 * @param job 任务信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.08.15 
	 */
	@PostMapping(value = "/executeOnce")
	@ResponseBody
	R<Object> executeOnceQuartzJob(@RequestBody QuartzJobParam job);
	
	/**
	 * 获取定时任务的执行日志记录列表
	 * @param condition 查询条件
	 * @return IPage<QuartzJobExecLogEntity> 分页信息
	 *
	 * @author zhouhui
	 * @since 2023.11.02 
	 */
	@PostMapping(value = "/getExecLogList")
	@ResponseBody
	R<IPage<QuartzJobExecLog>> getExecLogList(@RequestBody QuartzJobExecLogEntity condition);
	
	/**
	 * 获取定时任务操作的日志记录
	 * @param condition 查询条件
	 * @return IPage<QuartzJobOperateLog> 分页信息
	 *
	 * @author zhouhui
	 * @since 2023.11.18
	 */
	@PostMapping(value = "/getOperateLogList")
	@ResponseBody
	R<IPage<QuartzJobOperateLog>> getOperateLogList(@RequestBody QuartzJobOperateLogEntity condition);
}
